import request from '../../utils/request';

const reportForms = {
    state: {
        reportData: {},
        baseInfo: {}
    },
    mutations: {
        SET_REPORTDARA: (state, reportInfo) =>{
            state.reportData = reportInfo
        },
        SET_BASEINFO: (state, baseinfo)=>{
            state.baseInfo = baseinfo
        }
    },
    actions: {
        findAllReport({ commit, state },payload) {
            return new Promise((resolve, reject) => {
                request({
                    url: `/reportForm/findAllReport/${payload.isSchool}`,
                    method: "post",
                    data: payload.pageInfo
                }).then(data => {   
                    commit('SET_REPORTDARA', data.data);
                    resolve(data);
                }).catch(err => {
                    reject(err)
                })
            })

        },
        findByReportId({commit,state},payload){
            return new Promise((resolve,reject)=>{
                request({
                    url: `/reportForm/findByReportId/${payload.isSchool}/${payload.reportId}`,
                    method: 'get',
                }).then(data=>{
                    commit('SET_BASEINFO',data.data);
                    resolve(data);
                }).catch(err=>{
                    reject(err)
                })
            })
        }
    }
}
export default reportForms